package com.idu.entities;

// Generated Sep 5, 2014 3:35:31 PM by Hibernate Tools 3.4.0.CR1

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 * News generated by hbm2java
 */
@Entity
@Table(name = "news", catalog = "db_iduwebsite", uniqueConstraints = @UniqueConstraint(columnNames = "title"))
public class News {

	private Integer newsId;
	private Category category;
	private User user;
	private String title;
	private String content;
	private Date timeCreated;
	private String pathImage;
	private boolean active;
	private int idx;

	public News() {
	}

	public News(Category category, User user, String title, String content,
			Date timeCreated, boolean active, int idx) {
		this.category = category;
		this.user = user;
		this.title = title;
		this.content = content;
		this.timeCreated = timeCreated;
		this.active = active;
		this.idx = idx;
	}

	public News(Category category, User user, String title, String content,
			Date timeCreated, String pathImage, boolean active, int idx) {
		this.category = category;
		this.user = user;
		this.title = title;
		this.content = content;
		this.timeCreated = timeCreated;
		this.pathImage = pathImage;
		this.active = active;
		this.idx = idx;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "newsId", unique = true, nullable = false)
	public Integer getNewsId() {
		return this.newsId;
	}

	public void setNewsId(Integer newsId) {
		this.newsId = newsId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "categoryId", nullable = false)
	public Category getCategory() {
		return this.category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "userId", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "title", unique = true, nullable = false, length = 200)
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content", nullable = false, length = 65535)
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "timeCreated", nullable = false, length = 10)
	public Date getTimeCreated() {
		return this.timeCreated;
	}

	public void setTimeCreated(Date timeCreated) {
		this.timeCreated = timeCreated;
	}

	@Column(name = "pathImage", length = 200)
	public String getPathImage() {
		return this.pathImage;
	}

	public void setPathImage(String pathImage) {
		this.pathImage = pathImage;
	}

	@Column(name = "active", nullable = false)
	public boolean isActive() {
		return this.active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	@Column(name = "idx", nullable = false)
	public int getIdx() {
		return this.idx;
	}

	public void setIdx(int idx) {
		this.idx = idx;
	}

}
